#include "mainwindow.h"

#include "homepagecheck/homepage.h"
#include "homepagecheck/homepagecheckwidget.h"
#include "homepagecheck/homepagemodel.h"
#include <QStackedLayout>

MainWindow::MainWindow(QWidget *parent)
    : QFrame(parent)
{
    initUI();
    initconnect();
}

MainWindow::~MainWindow()
{

}

void MainWindow::initUI()
{
    mMainLayout = new QStackedLayout(this);

    mModel = new HomePageModel(this);
    mRatingWidget = new HomePageCheckWidget(mModel);
    mHomePage = new HomePage(mModel);

    mMainLayout->addWidget(mHomePage);
    mMainLayout->addWidget(mRatingWidget);

    mMainLayout->setCurrentIndex(0);
}

void MainWindow::initconnect()
{
    connect(mHomePage, SIGNAL(notifyShowCheckPage()), this, SLOT(showRating()));
    connect(mModel, SIGNAL(notifyShowHomepage()), this, SLOT(showHomePage()));
}

void MainWindow::showRating()
{
    mMainLayout->setCurrentIndex(1);
}

void MainWindow::showHomePage()
{
    mMainLayout->setCurrentIndex(0);
}
